package com.snail.readyvr.rest;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 * Created by MRKING on 2016/11/4.
 */

public class LoginRequestInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Request original = chain.request();
        Request request = original.newBuilder()
                .header("Accept-version", RestApiUtils.LOGIN_VERSION)
                .method(original.method(), original.body())
                .build();

        /*// try the request
        Response response = chain.proceed(request);

        int tryCount = 0;
        while (!response.isSuccessful() && tryCount < 3) {

            LogUtils.d("Request is not successful - " + tryCount);

            tryCount++;

            // retry the request
            response = chain.proceed(request);
        }

        // otherwise just pass the original response on
        return response;*/
        return chain.proceed(request);
    }
}
